Allow specifying -v multiple times
authorAlex Crichton <alex@alexcrichton.com>
Tue, 12 Apr 2016 21:55:19 +0000 (14:55 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 14 Jun 2016 14:35:40 +0000 (07:35 -0700)
This commit modifies the CLI interface to allow the verbose (-v) flag to be
specified multiple times. This'll be used soon to have `-vv` indicate that more
output should be generated than `-v` during a normal build.

Currently this commit changes the behavior of whether warnings are printed to
print warnings for the **entire DAG of dependencies** if `-vv` is specified.
That is, `--cap-lints` is never passed nor is any warning from build scripts if
`-vv` is specified.

30 files changed:
src/bin/bench.rs
src/bin/build.rs
src/bin/cargo.rs
src/bin/clean.rs
src/bin/doc.rs
src/bin/fetch.rs
src/bin/generate_lockfile.rs
src/bin/git_checkout.rs
src/bin/init.rs
src/bin/install.rs
src/bin/login.rs
src/bin/metadata.rs
src/bin/new.rs
src/bin/owner.rs
src/bin/package.rs
src/bin/pkgid.rs
src/bin/publish.rs
src/bin/run.rs
src/bin/rustc.rs
src/bin/rustdoc.rs
src/bin/search.rs
src/bin/test.rs
src/bin/uninstall.rs
src/bin/update.rs
src/bin/verify_project.rs
src/bin/yank.rs
src/cargo/ops/cargo_rustc/context.rs
src/cargo/util/config.rs
tests/build-script.rs
tests/registry.rs

index 3aff7fb1d8154fdfa88b2f789f590498b8642144..fc412ef1aaaab742109c15e04ba2eb074d953841 100644 (file)
@@ -11,7 +11,7 @@ pub struct Options {
     flag_no_default_features: bool,
     flag_target: Option<String>,
     flag_manifest_path: Option<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_lib: bool,
@@ -42,7 +42,7 @@ Options:
     --no-default-features        Do not build the `default` feature
     --target TRIPLE              Build for the target triple
     --manifest-path PATH         Path to the manifest to build benchmarks for
-    -v, --verbose                Use verbose output
+    -v, --verbose ...            Use verbose output
     -q, --quiet                  No output printed to stdout
     --color WHEN                 Coloring: auto, always, never
 
index 5a66ca754965223f2296f220ac769316bf4d89e0..25d69440edf74eeaa6f5f8e556abb2d0713ff0cc 100644 (file)
@@ -13,7 +13,7 @@ pub struct Options {
     flag_no_default_features: bool,
     flag_target: Option<String>,
     flag_manifest_path: Option<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_release: bool,
@@ -44,7 +44,7 @@ Options:
     --no-default-features        Do not build the `default` feature
     --target TRIPLE              Build for the target triple
     --manifest-path PATH         Path to the manifest to compile
-    -v, --verbose                Use verbose output
+    -v, --verbose ...            Use verbose output
     -q, --quiet                  No output printed to stdout
     --color WHEN                 Coloring: auto, always, never
 
index d7bd169cd989cf67b053d3d6088e251b9739cd87..3142bdd0a9d4ff038cd7dd73aa227d04342da49c 100644 (file)
@@ -21,7 +21,7 @@ use cargo::util::process_builder::process;
 pub struct Flags {
     flag_list: bool,
     flag_version: bool,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_explain: Option<String>,
@@ -41,7 +41,7 @@ Options:
     -V, --version       Print version info and exit
     --list              List installed commands
     --explain CODE      Run `rustc --explain CODE`
-    -v, --verbose       Use verbose output
+    -v, --verbose ...   Use verbose output
     -q, --quiet         No output printed to stdout
     --color WHEN        Coloring: auto, always, never
 
index 5bcb10aeb25602dc2a5ef64c3473e39fb8c94af8..af3968cf816f4af1f1cea6dceed9db9ed2c6a7d1 100644 (file)
@@ -9,7 +9,7 @@ pub struct Options {
     flag_package: Vec<String>,
     flag_target: Option<String>,
     flag_manifest_path: Option<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_release: bool,
@@ -27,7 +27,7 @@ Options:
     --manifest-path PATH         Path to the manifest to the package to clean
     --target TRIPLE              Target triple to clean output for (default all)
     --release                    Whether or not to clean release artifacts
-    -v, --verbose                Use verbose output
+    -v, --verbose ...            Use verbose output
     -q, --quiet                  No output printed to stdout
     --color WHEN                 Coloring: auto, always, never
 
index b7dbb1ade0c9455f95493542d88a8e65d5ad1a5a..37b5f60406ddefa9e2b76806419821fdd920fa3f 100644 (file)
@@ -12,7 +12,7 @@ pub struct Options {
     flag_no_deps: bool,
     flag_open: bool,
     flag_release: bool,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_package: Vec<String>,
@@ -39,7 +39,7 @@ Options:
     --no-default-features        Do not build the `default` feature
     --target TRIPLE              Build for the target triple
     --manifest-path PATH         Path to the manifest to document
-    -v, --verbose                Use verbose output
+    -v, --verbose ...            Use verbose output
     -q, --quiet                  No output printed to stdout
     --color WHEN                 Coloring: auto, always, never
 
index 1f32e8741549a5b139ce8e25afffce468c83e1f7..0d72fff44b528c1805a9a80ad76c005dd1b6cc9b 100644 (file)
@@ -5,7 +5,7 @@ use cargo::util::important_paths::find_root_manifest_for_wd;
 #[derive(RustcDecodable)]
 pub struct Options {
     flag_manifest_path: Option<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
 }
@@ -19,7 +19,7 @@ Usage:
 Options:
     -h, --help               Print this message
     --manifest-path PATH     Path to the manifest to fetch dependencies for
-    -v, --verbose            Use verbose output
+    -v, --verbose ...        Use verbose output
     -q, --quiet              No output printed to stdout
     --color WHEN             Coloring: auto, always, never
 
index 7e50eff265f7c0e4279fa4d1127cb4a098835670..83b44d4eeeffa8a18bb2514b12181a0675fcec3f 100644 (file)
@@ -7,7 +7,7 @@ use cargo::util::important_paths::find_root_manifest_for_wd;
 #[derive(RustcDecodable)]
 pub struct Options {
     flag_manifest_path: Option<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
 }
@@ -21,7 +21,7 @@ Usage:
 Options:
     -h, --help               Print this message
     --manifest-path PATH     Path to the manifest to generate a lockfile for
-    -v, --verbose            Use verbose output
+    -v, --verbose ...        Use verbose output
     -q, --quiet              No output printed to stdout
     --color WHEN             Coloring: auto, always, never
 ";
index 8d3e29ac2ebaae1a569cebd7848b68aafce13143..d3f49db6cdec48b071245ae25aaf7d618ee810dd 100644 (file)
@@ -6,7 +6,7 @@ use cargo::util::{Config, CliResult, CliError, human, ToUrl};
 pub struct Options {
     flag_url: String,
     flag_reference: String,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
 }
@@ -20,7 +20,7 @@ Usage:
 
 Options:
     -h, --help               Print this message
-    -v, --verbose            Use verbose output
+    -v, --verbose ...        Use verbose output
     -q, --quiet              No output printed to stdout
     --color WHEN             Coloring: auto, always, never
 ";
index 8856f8b35996a9d225a314859ff2c1f9d5de2456..3f02f057f3acf170164529aabf9e735bdf91f49d 100644 (file)
@@ -5,7 +5,7 @@ use cargo::util::{CliResult, Config};
 
 #[derive(RustcDecodable)]
 pub struct Options {
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_bin: bool,
@@ -28,7 +28,7 @@ Options:
                         control at all (none) overriding a global configuration.
     --bin               Use a binary instead of a library template
     --name NAME         Set the resulting package name
-    -v, --verbose       Use verbose output
+    -v, --verbose ...   Use verbose output
     -q, --quiet         No output printed to stdout
     --color WHEN        Coloring: auto, always, never
 ";
index 3f8d50baebe69daf786b15b4c0b14f21e6992f74..5422375518fafdc1d8195dca018371c736b5b5c5 100644 (file)
@@ -10,7 +10,7 @@ pub struct Options {
     flag_debug: bool,
     flag_bin: Vec<String>,
     flag_example: Vec<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_root: Option<String>,
@@ -53,7 +53,7 @@ Build and install options:
     --bin NAME                Only install the binary NAME
     --example EXAMPLE         Install the example EXAMPLE instead of binaries
     --root DIR                Directory to install packages into
-    -v, --verbose             Use verbose output
+    -v, --verbose ...         Use verbose output
     -q, --quiet               Less output printed to stdout
     --color WHEN              Coloring: auto, always, never
 
index bfb8418e40e8d5f707f6dfd56acfb179b6378da8..50d8249be7fa2e522972b82f7c0ae7e178c4e3f9 100644 (file)
@@ -10,7 +10,7 @@ use cargo::util::{CliResult, Config, human, ChainError};
 pub struct Options {
     flag_host: Option<String>,
     arg_token: Option<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
 }
@@ -24,7 +24,7 @@ Usage:
 Options:
     -h, --help               Print this message
     --host HOST              Host to set the token for
-    -v, --verbose            Use verbose output
+    -v, --verbose ...        Use verbose output
     -q, --quiet              No output printed to stdout
     --color WHEN             Coloring: auto, always, never
 
index c8375d95c95116c6f768abaa5df6f716297689e3..b959be2c0e31a4700c349f8c9710f32c28ccbeea 100644 (file)
@@ -16,7 +16,7 @@ pub struct Options {
     flag_no_default_features: bool,
     flag_no_deps: bool,
     flag_quiet: Option<bool>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
 }
 
 pub const USAGE: &'static str = "
@@ -35,7 +35,7 @@ Options:
     --manifest-path PATH       Path to the manifest
     --format-version VERSION   Format version [default: 1]
                                Valid values: 1
-    -v, --verbose              Use verbose output
+    -v, --verbose ...          Use verbose output
     -q, --quiet                No output printed to stdout
     --color WHEN               Coloring: auto, always, never
 ";
index 340fab90b4eee146b22469a0cd938b9f1f02eecd..70f9018e497da257d5830c5ded7ac66138635ca2 100644 (file)
@@ -5,7 +5,7 @@ use cargo::util::{CliResult, Config};
 
 #[derive(RustcDecodable)]
 pub struct Options {
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_bin: bool,
@@ -28,7 +28,7 @@ Options:
                         control at all (none) overriding a global configuration.
     --bin               Use a binary instead of a library template
     --name NAME         Set the resulting package name
-    -v, --verbose       Use verbose output
+    -v, --verbose ...   Use verbose output
     -q, --quiet         No output printed to stdout
     --color WHEN        Coloring: auto, always, never
 ";
index 33f49e51140a1a708b2d3a8131dfc964299cafc5..1eb0242957631b802d06228fdad3fecfc08d6073 100644 (file)
@@ -8,7 +8,7 @@ pub struct Options {
     flag_add: Option<Vec<String>>,
     flag_remove: Option<Vec<String>>,
     flag_index: Option<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_list: bool,
@@ -27,7 +27,7 @@ Options:
     -l, --list               List owners of a crate
     --index INDEX            Registry index to modify owners for
     --token TOKEN            API token to use when authenticating
-    -v, --verbose            Use verbose output
+    -v, --verbose ...        Use verbose output
     -q, --quiet              No output printed to stdout
     --color WHEN             Coloring: auto, always, never
 
index be4a94cad6c0402c468a94c9508f794ead9fea73..0336331a21bc74a90784988bd9bd1e8829bbf1d4 100644 (file)
@@ -4,7 +4,7 @@ use cargo::util::important_paths::find_root_manifest_for_wd;
 
 #[derive(RustcDecodable)]
 pub struct Options {
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_manifest_path: Option<String>,
@@ -27,7 +27,7 @@ Options:
     --no-metadata           Ignore warnings about a lack of human-usable metadata
     --allow-dirty           Allow dirty working directories to be packaged
     --manifest-path PATH    Path to the manifest to compile
-    -v, --verbose           Use verbose output
+    -v, --verbose ...       Use verbose output
     -q, --quiet             No output printed to stdout
     --color WHEN            Coloring: auto, always, never
 
index 68e53236f20fe0cfe0b380497702faab999ef10f..beff81e3db9e66b76190bf302665d83b37720a65 100644 (file)
@@ -4,7 +4,7 @@ use cargo::util::important_paths::{find_root_manifest_for_wd};
 
 #[derive(RustcDecodable)]
 pub struct Options {
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_manifest_path: Option<String>,
@@ -20,7 +20,7 @@ Usage:
 Options:
     -h, --help               Print this message
     --manifest-path PATH     Path to the manifest to the package to clean
-    -v, --verbose            Use verbose output
+    -v, --verbose ...        Use verbose output
     -q, --quiet              No output printed to stdout
     --color WHEN             Coloring: auto, always, never
 
index 73466c27fbbd1aff94c7a911357b818598a0da67..32b7f5e400c1ae670d1793b40d05b14091cee05e 100644 (file)
@@ -7,7 +7,7 @@ pub struct Options {
     flag_host: Option<String>,
     flag_token: Option<String>,
     flag_manifest_path: Option<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_no_verify: bool,
@@ -27,7 +27,7 @@ Options:
     --no-verify              Don't verify package tarball before publish
     --allow-dirty            Allow publishing with a dirty source directory
     --manifest-path PATH     Path to the manifest of the package to publish
-    -v, --verbose            Use verbose output
+    -v, --verbose ...        Use verbose output
     -q, --quiet              No output printed to stdout
     --color WHEN             Coloring: auto, always, never
 
index 789c90e4c89d64c5ad4df5007be4457a546b3b2f..7515eba5b8e8cba635000593410d130216de6028 100644 (file)
@@ -11,7 +11,7 @@ pub struct Options {
     flag_no_default_features: bool,
     flag_target: Option<String>,
     flag_manifest_path: Option<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_release: bool,
@@ -34,7 +34,7 @@ Options:
     --no-default-features   Do not build the `default` feature
     --target TRIPLE         Build for the target triple
     --manifest-path PATH    Path to the manifest to execute
-    -v, --verbose           Use verbose output
+    -v, --verbose ...       Use verbose output
     -q, --quiet             No output printed to stdout
     --color WHEN            Coloring: auto, always, never
 
index 51fec6d86803d8cd2e5703760cea3bddd82b6232..2c2e850539bbe226f5b32f1b5489dfcbafac779d 100644 (file)
@@ -14,7 +14,7 @@ pub struct Options {
     flag_no_default_features: bool,
     flag_target: Option<String>,
     flag_manifest_path: Option<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_release: bool,
@@ -47,7 +47,7 @@ Options:
     --no-default-features    Do not compile default features for the package
     --target TRIPLE          Target triple which compiles will be for
     --manifest-path PATH     Path to the manifest to fetch dependencies for
-    -v, --verbose            Use verbose output
+    -v, --verbose ...        Use verbose output
     -q, --quiet              No output printed to stdout
     --color WHEN             Coloring: auto, always, never
 
index ed53d769ba8b18f86ce663fe034ef6ad19316202..8ed63d991f9c9c93b542a124c5903edd308e557f 100644 (file)
@@ -11,7 +11,7 @@ pub struct Options {
     flag_manifest_path: Option<String>,
     flag_no_default_features: bool,
     flag_open: bool,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_release: bool,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
@@ -44,7 +44,7 @@ Options:
     --no-default-features    Do not build the `default` feature
     --target TRIPLE          Build for the target triple
     --manifest-path PATH     Path to the manifest to document
-    -v, --verbose            Use verbose output
+    -v, --verbose ...        Use verbose output
     -q, --quiet              No output printed to stdout
     --color WHEN             Coloring: auto, always, never
 
index 2eae9173c9cea3a5e571f9ebf9113b952accc2c1..4d1f1ea3bf13361e77df5fbd94ec8a1abd207748 100644 (file)
@@ -6,7 +6,7 @@ use std::cmp;
 #[derive(RustcDecodable)]
 pub struct Options {
     flag_host: Option<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_limit: Option<u32>,
@@ -23,7 +23,7 @@ Usage:
 Options:
     -h, --help               Print this message
     --host HOST              Host of a registry to search in
-    -v, --verbose            Use verbose output
+    -v, --verbose ...        Use verbose output
     -q, --quiet              No output printed to stdout
     --color WHEN             Coloring: auto, always, never
     --limit LIMIT            Limit the number of results (default: 10, max: 100)
index 8f2d0feef25741e2e3411c6e9dbd88f5c8b7f8b5..2d4dca94313f498f30a1c81389d34bc3e66c62a5 100644 (file)
@@ -18,7 +18,7 @@ pub struct Options {
     flag_example: Vec<String>,
     flag_test: Vec<String>,
     flag_bench: Vec<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_release: bool,
@@ -47,7 +47,7 @@ Options:
     --no-default-features        Do not build the `default` feature
     --target TRIPLE              Build for the target triple
     --manifest-path PATH         Path to the manifest to build tests for
-    -v, --verbose                Use verbose output
+    -v, --verbose ...            Use verbose output
     -q, --quiet                  No output printed to stdout
     --color WHEN                 Coloring: auto, always, never
     --no-fail-fast               Run all tests regardless of failure
index ace6a25007e89480f1770d1159deab95ccb0c6cb..046997a44fb860c44cdae55693e70388a484c8a5 100644 (file)
@@ -5,7 +5,7 @@ use cargo::util::{CliResult, Config};
 pub struct Options {
     flag_bin: Vec<String>,
     flag_root: Option<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
 
@@ -23,7 +23,7 @@ Options:
     -h, --help                Print this message
     --root DIR                Directory to uninstall packages from
     --bin NAME                Only uninstall the binary NAME
-    -v, --verbose             Use verbose output
+    -v, --verbose ...         Use verbose output
     -q, --quiet               Less output printed to stdout
     --color WHEN              Coloring: auto, always, never
 
index 77e4c470cc4e0d88237e426ed7904e5120056b2b..12d26883888912c433227dfb0be8dfc4dc98f8a1 100644 (file)
@@ -10,7 +10,7 @@ pub struct Options {
     flag_aggressive: bool,
     flag_precise: Option<String>,
     flag_manifest_path: Option<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
 }
@@ -27,7 +27,7 @@ Options:
     --aggressive                 Force updating all dependencies of <name> as well
     --precise PRECISE            Update a single dependency to exactly PRECISE
     --manifest-path PATH         Path to the crate's manifest
-    -v, --verbose                Use verbose output
+    -v, --verbose ...            Use verbose output
     -q, --quiet                  No output printed to stdout
     --color WHEN                 Coloring: auto, always, never
 
index 7079a4a6e97afb7ce61b40e77206d3dccba1f0c1..0ce407e08c4783560a61b81096c9509c97a123b0 100644 (file)
@@ -13,7 +13,7 @@ pub type Error = HashMap<String, String>;
 #[derive(RustcDecodable)]
 pub struct Flags {
     flag_manifest_path: Option<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
 }
@@ -28,7 +28,7 @@ Usage:
 Options:
     -h, --help              Print this message
     --manifest-path PATH    Path to the manifest to verify
-    -v, --verbose           Use verbose output
+    -v, --verbose ...       Use verbose output
     -q, --quiet             No output printed to stdout
     --color WHEN            Coloring: auto, always, never
 ";
index 60718c7645d6fe555181774b63d08d58e27dac37..a869f36fffcb1b5ac9cd78ef1fea584fe40cea25 100644 (file)
@@ -7,7 +7,7 @@ pub struct Options {
     flag_token: Option<String>,
     flag_vers: Option<String>,
     flag_index: Option<String>,
-    flag_verbose: Option<bool>,
+    flag_verbose: u32,
     flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_undo: bool,
@@ -25,7 +25,7 @@ Options:
     --undo              Undo a yank, putting a version back into the index
     --index INDEX       Registry index to yank from
     --token TOKEN       API token to use when authenticating
-    -v, --verbose       Use verbose output
+    -v, --verbose ...   Use verbose output
     -q, --quiet         No output printed to stdout
     --color WHEN        Coloring: auto, always, never
 
index 74e14cf378396929fe8f5e54043a10e307393ff3..bf458bcbf5c8113a7dda021843374aa2af2417c8 100644 (file)
@@ -648,7 +648,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
     }
 
     pub fn show_warnings(&self, pkg: &PackageId) -> bool {
-        pkg == self.resolve.root() || pkg.source_id().is_path()
+        pkg == self.resolve.root() || pkg.source_id().is_path() ||
+            self.config.extra_verbose()
     }
 }
 
index 53ad520e609cdbc04e8d22a0b4a6e0aefa027ce5..2ca6a2001c0ada32840b6ef9c98c0808acc14ce4 100644 (file)
@@ -31,6 +31,7 @@ pub struct Config {
     rustc: PathBuf,
     rustdoc: PathBuf,
     target_dir: RefCell<Option<Filesystem>>,
+    extra_verbose: Cell<bool>,
 }
 
 impl Config {
@@ -47,6 +48,7 @@ impl Config {
             rustc: PathBuf::from("rustc"),
             rustdoc: PathBuf::from("rustdoc"),
             target_dir: RefCell::new(None),
+            extra_verbose: Cell::new(false),
         };
 
         try!(cfg.scrape_tool_config());
@@ -287,9 +289,11 @@ impl Config {
     }
 
     pub fn configure_shell(&self,
-                           verbose: Option<bool>,
+                           verbose: u32,
                            quiet: Option<bool>,
                            color: &Option<String>) -> CargoResult<()> {
+        let extra_verbose = verbose >= 2;
+        let verbose = if verbose == 0 {None} else {Some(true)};
         let cfg_verbose = try!(self.get_bool("term.verbose")).map(|v| v.val);
         let cfg_color = try!(self.get_string("term.color")).map(|v| v.val);
         let color = color.as_ref().or(cfg_color.as_ref());
@@ -320,10 +324,15 @@ impl Config {
 
         self.shell().set_verbosity(verbosity);
         try!(self.shell().set_color_config(color.map(|s| &s[..])));
+        self.extra_verbose.set(extra_verbose);
 
         Ok(())
     }
 
+    pub fn extra_verbose(&self) -> bool {
+        self.extra_verbose.get()
+    }
+
     fn load_values(&self) -> CargoResult<()> {
         let mut cfg = CV::Table(HashMap::new(), PathBuf::from("."));
 
index 1a5ef7c032e883e61f3c4f3b1142a0f9a17a9a11..f555c22a3269de0ff7506a3ad7522a89f2f50670 100644 (file)
@@ -4,15 +4,10 @@ extern crate hamcrest;
 use std::fs::{self, File};
 use std::io::prelude::*;
 
-<<<<<<< 07c1d9900de40c59b898d08d64273447560ffbe3:tests/build-script.rs
 use cargotest::{rustc_host, is_nightly, sleep_ms};
 use cargotest::support::{project, execs};
 use cargotest::support::paths::CargoPathExt;
-=======
-use support::{project, execs};
-use support::paths::CargoPathExt;
-use support::registry::Package;
->>>>>>> Forward warnings from build scripts:tests/test_cargo_compile_custom_build.rs
+use cargotest::support::registry::Package;
 use hamcrest::{assert_that, existing_file, existing_dir};
 
 #[test]
@@ -2087,3 +2082,42 @@ fn warnings_hidden_for_upstream() {
                 execs().with_status(0)
                        .with_stderr(""));
 }
+
+#[test]
+fn warnings_printed_on_vv() {
+    Package::new("bar", "0.1.0")
+            .file("build.rs", r#"
+                fn main() {
+                    println!("cargo:warning=foo");
+                    println!("cargo:warning=bar");
+                }
+            "#)
+            .file("Cargo.toml", r#"
+                [project]
+                name = "bar"
+                version = "0.1.0"
+                authors = []
+                build = "build.rs"
+            "#)
+            .file("src/lib.rs", "")
+            .publish();
+
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [project]
+            name = "foo"
+            version = "0.5.0"
+            authors = []
+
+            [dependencies]
+            bar = "*"
+        "#)
+        .file("src/lib.rs", "");
+
+    assert_that(p.cargo_process("build").arg("-vv"),
+                execs().with_status(0)
+                       .with_stderr("\
+warning: foo
+warning: bar
+"));
+}
index cb517c91c1bb968ac8b5623ee0acc580a927b70e..83ddb6b7427860e92572ad35bd27fb32285c2f9b 100644 (file)
@@ -1045,3 +1045,28 @@ fn resolve_and_backtracking() {
     assert_that(p.cargo("build"),
                 execs().with_status(0));
 }
+
+#[test]
+fn upstream_warnings_on_extra_verbose() {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [project]
+            name = "bar"
+            version = "0.5.0"
+            authors = []
+
+            [dependencies]
+            foo = "*"
+        "#)
+        .file("src/main.rs", "fn main() {}");
+    p.build();
+
+    Package::new("foo", "0.1.0")
+            .file("src/lib.rs", "fn unused() {}")
+            .publish();
+
+    assert_that(p.cargo("build").arg("-vv"),
+                execs().with_status(0).with_stderr_contains("\
+[..] warning: function is never used[..]
+"));
+}